package com.mjlf.jol;

import org.openjdk.jol.info.ClassLayout;

/**
 * @ClassName JolTest1
 * @auther mjlf
 * @Date 2019/7/16 9:38
 * @Description TODO
 */
public class JolTest3 {
    public static A a;

    public static void main(String[] args) {
//        try {
//            Thread.sleep(5000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        a = new A();
        System.out.println("before hash");
        //没有计算hashcode之前的对象头
        System.out.println(ClassLayout.parseInstance(a).toPrintable());

        sync();

        //计算hashcode后
        System.out.println("after hash");
        System.out.println(ClassLayout.parseInstance(a).toPrintable());
    }

    public static void sync() {
        synchronized (a) {
            System.out.println("不知道输出啥");
        }
    }
}
